<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<BOSS.Framework.Search.Result.ISearchResult>" %>
<%@ Import Namespace="BOSS.Domain.Customers" %>
<%@ Import Namespace="BOSS.Web.Extensions" %>

<% 
    var data = new
    {
        totalCount = Model.TotalCount,
        rows = Model.UnderlayerItems.OfType<CustomerCard>().Select(x => new 
        { 
            Id = x.Id,
            Url = Url.Action("CustomerCardDetails", "Customer", new { id = x.Id }), 
            CardNumber = x.CardNumber,
            Cardholder = new 
            { 
                Id = x.Cardholder.Id, 
                Name = x.Cardholder.Name 
            },
            CustomerAccount = new 
            { 
                Url = Url.Action("CustomerAccountDetails", "Customer", new { id = x.CustomerAccount.Id }), 
                AccountNumber = x.CustomerAccount.AccountNumber 
            },
            State = x.State.GetDescription(),
            ActivationDate = Html.EncodeDateTime(x.ActivationDate)
        })
    }; 
%>
<%= Html.ToJson(data) %>